<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- 引入layui的样式文件和脚本语法-->
<link rel="stylesheet" type="text/css" href="layui/css/layui.css" />
<script src="layui/layui.js" type="text/javascript" charset="UTF-8"></script>
</head>
<body>
	<form action="EmpServlet?method=getEmpList" method="post">
		姓名：<input type="text" name="name" /> <br>
		 性别：<input type="radio"name="sex" />男
		  <input type="radio" name="sex" />女<br>
		   月薪：<input type="number" name="sal" /><br> 
		   部门编号：<input type="text" name="did" /><br>
		   <input type="text" name="url" style="display:none"/><br>
		<button type="button" class="layui-btn" id="test1">
			<i class="layui-icon">&#xe67c;</i>上传图片
		</button>
		<input type="submit" value="添加" />
		<script>
	    if('${res}'){
	    	alert('${res}')
	    }
		layui.use('upload', function() {
			var upload = layui.upload;
			var $ = layui.$;
			//执行实例
			var uploadInst = upload.render({
				elem :'#test1', //绑定元素
				url : 'ImgServlet?method=uploadImg', //上传接口
				done : function(res) {
					//上传完毕回调
					console.log(res);
					if(res.code==0){
						$("#showImg").attr("value","imgs/"+res.data);
					}
				},
				error : function() {
					//请求异常回调
				}
			});
		});
	</script>
	</form>
</body>
</html>